home *** CD-ROM | disk | FTP | other *** search
-
- /*
- Copyright (C) 1995 Rolf Jakob <rjakob@duffy1.franken.de>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- /* get a word */
-
- char *getword(char *buffer,char *word)
- {
- char *p,*s;
- char sep;
- char *separray=" \t=\n,:;";
-
- *word=0;
- p=buffer;
- /*
- while (*p && (*p==' ' || *p=='\t' || *p=='=' || *p=='\n' || *p==',')) p++;
- */
- while (*p && strchr(separray,*p)) p++;
- if (*p==0) return(NULL);
- s=p;
- if (*p=='\'' || *p=='\"')
- {
- sep=*(p++);
- while (*p && *p!=sep) p++;
- strncpy(word,s+1,p-s-1);
- word[p-s-1]=0;
- if (!(*p)) return(NULL);
- return(p+1);
- }
- else
- {
- /*
- while (*p && *p!=' ' && *p!='\t' && *p!='=' && *p!='\n' && *p!=',') p++;
- */
- while (*p && !(strchr(separray,*p))) p++;
- strncpy(word,s,p-s);
- word[p-s]=0;
- if (!(*p)) return(NULL);
- return(p+1);
- }
- }
-
- /* get the last word */
-
- char *getlastword(char *buffer, char *word)
- {
- char *p;
- char hword[512];
-
- p=getword(buffer,word);
- while(p && *word) { strcpy(hword,word); p=getword(p,word); }
- if (!*word) strcpy(word,hword);
- return(word);
- }
-